package com.qilin.hscs.util;

import com.qilin.hscs.enums.ResultEnum;
import com.qilin.hscs.enums.UserRoleEnum;
import com.qilin.hscs.exception.SMException;

/**
 * Created by 10188 on 2018/5/10.
 */
public class IsUserCanDo {

    public static void judge(Integer role,String operationName) {
        if (role == null) {
           role=0;
        }
        if (role == UserRoleEnum.SUPER_ADMIN.getRole() || role == UserRoleEnum.ADMIN.getRole()) {
            return ;
        }
        switch (operationName) {
            case "bindHost":
            case "findHostsByUserPhone":
            case "switchHost":
            case "releaseHost":
            case "findHostByMac":
                return;
            default:
                throw new SMException(ResultEnum.N0_PERMISSSION);
        }
    }
}
